#pragma once
#include "graphic.h"
#include "DeviceData.h"
#include <vector>

class Device :
	public Graphic
{
public:
	Device(void);
	virtual ~Device(void);
public:
	static Device* GetDevByID(int id, int devTypeBegin, int devTypeEnd);
	virtual void   Serialize(CArchive& ar);
	virtual void   setNamePos(void) = 0;
	virtual CPoint getNeerPoint(CPoint pt, int& nFlag) { return CPoint(0, 0); nFlag = -1;}
	virtual void   extendDevice(CPoint screenPt, int nFlag) {}

	void   drawMutiLine  (CPaintDC& dc,     CPoint pt[],      int nPt);
	void   drawMutiInsu  (CPaintDC& dc,     CPoint pt[],      int nPt);
	void   drawSealFrame (CPaintDC& dc,     CPoint sealPt[],  int nPt);
	CPoint getCrossPoint (CPoint& line1Pt1, CPoint& line1Pt2, CPoint& line2Pt1, CPoint& line2Pt2);
	bool   isTwoPointNeer(CPoint& pt1,      CPoint& pt2) { return abs(pt1.x - pt2.x) < 11 && abs(pt1.y - pt2.y) < 21; }
	void   swapPoint(CPoint& pt1, CPoint& pt2);

	DECLARE_MESSAGE_MAP()
	afx_msg void OnMouseLeave();
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
public:
	DeviceData _data;
	bool       _bSealed;
public:
	enum INSULATION_TYPE
	{
		INSU_NORMAL,
		INSU_INTRUDE_LIMIT,
		INSU_NULL,
	};
public:
	static CString __stationName;
	static int     __stationID;

	static CPen   __SECTION_PEN;
	static CPen   __SEAL_PEN;
	static CPen   __INSU_PEN;
	static CPen   __INSU_NEER_PEN;
	static CBrush __SIGNAL_BRUSH[3];
	
	static int __sectionWidth;
	static int __sealWidth;
	static int __insuWidth;
	static int __insuHeight;

	static int __signalR;

	static int __dgree;
	static int __switchHeight;
	static int __nailHeight;
	static int __nailX;
	afx_msg void OnWindowPosChanged(WINDOWPOS* lpwndpos);
};

